package com.hongkzh.www.shop.service;

import com.hongkzh.www.adv.service.BaseService;
import com.jfinal.aop.Before;
import com.jfinal.kit.Kv;
import com.jfinal.plugin.activerecord.Db;
import com.jfinal.plugin.activerecord.Record;
import com.jfinal.plugin.activerecord.tx.Tx;

import java.util.List;

public class AccountService extends BaseService {


    @Before(Tx.class)
    public int saveAccount(String id, String loginUid, String bankNo, String cardNo, String payPawwrod, String openingBank, String openingName, String bankPhone, String bankPositiveImg, String banBackImg, String cardPositiveImg, String cardBackImg, String shopId,String isUpdate) {
        Kv cond = Kv.by("id", id).set("loginUid", loginUid).set("bankNo", bankNo).set("cardNo", cardNo).set("payPawwrod", payPawwrod).set("openingBank", openingBank).set("openingName", openingName).set("bankPhone", bankPhone).set("bankPositiveImg", bankPositiveImg).set("banBackImg", banBackImg).set("cardPositiveImg", cardPositiveImg).set("cardBackImg", cardBackImg).set("shopId", shopId);
        int result = 0;
        if ("0".equals(isUpdate)) {
            result = Db.update(Db.getSqlPara("account.saveAccount", cond));
        }else{
            result = Db.update(Db.getSqlPara("account.updateAccount", cond));
        }
        return result;
    }

    @Before(Tx.class)
    public int applyForWithdrawal(String loginUid, String orderNumber) {
        int result = Db.update(Db.getSqlPara("account.applyForWithdrawal", loginUid, orderNumber));
        return result;
    }


    public List<Record> withdrawalInformation(String loginUid) {

        List<Record> list = Db.find(Db.getSqlPara("account.getWithdrawalInformation", loginUid));
        for (Record r : list) {
            doAccountPath(r);
        }
        return list;
    }

}
